package com.healthy.mapper;

import com.healthy.entity.Customerprofile;
import com.healthy.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {


    //    查询所有
    @Select("select id,account,name from t_user")
    List<User> cuUser();


    @Select("select * from t_user where account = #{account}")
    User getUserByAccount(String account);

    User getUserByPhone(String phone);

    List<User> getList(@Param("user") User user);

    //删除
    @Delete("delete from t_user where id = #{id}")
    int cuDeleteByid(int id);

    //修改
    @Update("update t_user set account = #{account}, name = #{name} where id = #{id}")
    int cuUpdateByid(@Param("id") int id,@Param("account") String account,@Param("name") String name);

//    @Insert("insert into t_user (name, account, password) values ( #{name}, #{account}, #{password})")
//    int saveUser(User user);
    // 和上面的写法完全一致
    @Insert("insert into t_user (name, account, password) values ( #{user.name}, #{user.account}, #{user.password})")
    int saveUser(@Param("user") User user);

    @Update("update t_user set token = #{token} where id = #{id}")
    int setTokenToUser(@Param("token") String token, @Param("id") Integer id);

    @Select("select * from t_user where token = #{token}")
    User getUserByToken(String token);

}
